import java.util.Scanner;

public class Text1 {
    //水仙花数
    public static void main(String[] args) {
        for (int i = 0; i <= 99999; i++) {
            int tmp = i;
            int sum = 0;
            int count = 0;
            while(tmp != 0) {
                count++;
                tmp /= 10;
            }
            tmp = i;
            while(tmp != 0) {
                sum += Math.pow(tmp%10, count);
                tmp /= 10;
            }
            if(i == sum) {
                System.out.println(i);
            }
        }
    }
}
